/**
 * CustomComponentsAction.java
 *
 * Copyright (c) 2009 viorelt All Rights Reserved.
 *
 * This source file may not be copied, modified or redistributed,
 * in whole or in part, in any form or for any reason, without the express
 * written consent of viorelt .
 **/
package ro.prjmanager.web.actions;

import ro.prjmanager.core.annotations.*;
import ro.prjmanager.model.CustomComponents;
import ro.prjmanager.web.annotation.NomenclatorTarget;
import ro.prjmanager.web.annotation.Service;

@Service(target = "customcomponentsService")
@NomenclatorTarget(addTarget = "add",deleteTarget = "del",editTarget = "edit",
        resource = "/pages/nomenclators/customcomponents/customcomponents.jsp",
        onFaildReturn = "/pages/nomenclators/customcomponents/customcomponents.jsp")
@List(serviceName = "customcomponentsService",
        caption = "Custom Components List",
        editUrl = "%context_path%/actions/CustomComponents.action",
        id = "1", height = 200, rowNum = 10,
        url = "%context_path%/customcomponents.lst",closeAfterAdd = false,closeAfterEdit = false)
public class CustomComponentsAction extends GenericAction<CustomComponents> {
    //define attributes that maps all columns of the coresponding table
    //this attribute maps the primary key column ID
    @Id
    private java.lang.Integer idL;

    @Column(name = "name", caption = "Nume", index = "name", width = 150, editOptions = @EditOptions(pos = 1, required = true, prefix = "(*)"))
    private String name;
    //this attribute maps the foreign key column FK_MODEL
    @Column(name = "fkModel", caption = "Model", index = "fkModel", width = 150, editOptions = @EditOptions(pos = 2,edittype = "select",size = 1))
    @SelectOption(id="fkModel",nameOption = "databaseName",serviceName = "modelsService")
    private java.lang.Integer fkModel;
    //this attribute maps the foreign key column FK_COMPONENTS
    @Column(name = "fkComponents", caption = "Componenta", index = "fkComponents", width = 150, editOptions = @EditOptions(pos = 3,edittype = "select",size = 1))
    @SelectOption(id="fkComponents",serviceName = "genericcomponentsService")
    private java.lang.Integer fkComponents;
    //this attribute maps the foreign key column FK_GROUP_COMP
    @Column(name = "fkGroups", caption = "Grup", index = "fkGroups", width = 150, editOptions = @EditOptions(pos = 4,edittype = "select",size = 1))
    @SelectOption(id="fkGroups",nameOption = "name", serviceName = "groupsService")
    private java.lang.Integer fkGroups;
    //end mapping columns
    @Column(name = "componentDetails", caption = "Detalii comp", index = "componentDetails", width = 150, editOptions = @EditOptions(pos = 5,edittype = "select",size = 1))
    @SelectOption(id="componentDetails",nameOption = "detail", serviceName = "componentdetailsService")
    private java.lang.Integer componentDetails;
                                                                       
    public Integer getIdL() {
        if(getId()!=null&&!getId().isEmpty()&&!getId().equals("_empty"))
          idL=Integer.valueOf(getId());
        return idL;
    }

    public void setIdL(Integer idL) {
        this.idL = idL;
        if(idL!=null)
            this.setId(String.valueOf(idL));
    }

    public java.lang.Integer getFkModel() {
        return fkModel;
    }

    public void setFkModel(java.lang.Integer fkModel) {
        this.fkModel = fkModel;
    }

    public java.lang.Integer getFkComponents() {
        return fkComponents;
    }

    public void setFkComponents(java.lang.Integer fkComponents) {
        this.fkComponents = fkComponents;
    }

    public java.lang.Integer getFkGroups() {
        return fkGroups;
    }

    public void setFkGroups(java.lang.Integer fkGroups) {
        this.fkGroups = fkGroups;
    }

    public java.lang.Integer getComponentDetails() {
        return componentDetails;
    }

    public void setComponentDetails(java.lang.Integer componentDetails) {
        this.componentDetails = componentDetails;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void add() {
        CustomComponents customComponents=getModel();
        getService().create(customComponents);

    }
    public void edit() {
        CustomComponents customComponents=getModel();
        getService().update(customComponents);
    }
    

}
